using System;
using System.Collections;
using UnityEngine;

public class ArrangeAnchorsRecursive : MonoBehaviour
{
	private void OnDrawGizmos()
	{
		RectTransform rectTransform = base.transform as RectTransform;
		RectTransform rectTransform2 = rectTransform.parent as RectTransform;
		Vector2 pivot = rectTransform2.pivot;
		rectTransform2.pivot = Vector2.zero;
		Rect rect = rectTransform.rect;
		float width = rect.width;
		float height = rect.height;
		Vector3 localPosition = rectTransform.localPosition;
		float x = localPosition.x;
		Vector3 localPosition2 = rectTransform.localPosition;
		float y = localPosition2.y;
		Rect rect2 = rectTransform2.rect;
		rectTransform.anchorMin = new Vector2((x - width / 2f) / rect2.width, (y - height / 2f) / rect2.height);
		rectTransform.anchorMax = new Vector2((x + width / 2f) / rect2.width, (y + height / 2f) / rect2.height);
		rectTransform.offsetMax = Vector2.zero;
		rectTransform.offsetMin = Vector2.zero;
		rectTransform2.pivot = pivot;
		IEnumerator enumerator = base.transform.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Transform transform = (Transform)enumerator.Current;
				transform.gameObject.AddComponent<ArrangeAnchorsRecursive>();
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
		UnityEngine.Object.DestroyImmediate(this);
	}
}
